package com.china.adapter;

import android.content.Context;
import android.text.SpannableString;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.china.utils.ExpressionUtil;

import java.util.List;

/**
 * Created by Administrator on 2016/5/13.
 */
public class TweetDetailAdapter extends BaseAdapter {

    private List<String> list;
    private Context context;

    public TweetDetailAdapter(List<String> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        TextView textView = new TextView(context);
        String zhengze = "smiley_[0-3]{3}|smiley_[0-9]{2}|smiley_[0-9]";
        SpannableString string = ExpressionUtil.getExpressionString(context,list.get(position),zhengze);
        textView.setText(string);
        return textView;
    }
}
